<?php
/**
 *
 *
 * This file is part of Webappkit, a packages system for PHP web apps
 * @link http://webappkit.net
 * @package
 * @subpackage
 * @author J.Ducastel <nospam0@ducastel.name>
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 */

class WakPhpFile extends WakTextFile {

    /**
     * list defined classes
     * @return array (string)
     */
    public function definedClasses() {
        $classes = array();
        $tokens = $this->getTokens(); //echo '<pre>';
        while ($token = next($tokens)) {
            if (is_array($token) and $token[0]==T_CLASS) {
                $t_space = next($tokens);
                $t_class = next($tokens);
                // print_r($t_class);
                $classes[] = $t_class[1];
            }
        }
        // echo '<pre>'; print_r($classes);
        return $classes;
        // echo '<pre>'; print_r($tokens);
    }

    public function getTokens() {
        return token_get_all($this->getContent());
    }
}